home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Internet Strate…Tools for the Enterprise
/
Microsoft Internet Strategy & Tools for the Enterprise.iso
/
content
/
devel.tls
/
icp
/
vbsamp
/
smplhttp.exe
/
FRMHTTP.FRM
(
.txt
)
next >
Wrap
Visual Basic Form
|
1996-03-28
|
13KB
|
257 lines
VERSION 4.00
Begin VB.Form frmHTTP
BorderStyle = 3 'Fixed Dialog
Caption = "Simple HTTP..."
ClientHeight = 5805
ClientLeft = 855
ClientTop = 1140
ClientWidth = 8130
Height = 6210
Icon = "frmHTTP.frx":0000
Left = 795
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 5805
ScaleWidth = 8130
ShowInTaskbar = 0 'False
Top = 795
Width = 8250
Begin VB.TextBox txtFileName
Height = 285
Left = 720
TabIndex = 6
Top = 390
Width = 6255
End
Begin VB.ComboBox cmbURL
Height = 315
Left = 720
TabIndex = 1
Text = "http://www.microsoft.com/"
Top = 30
Width = 6255
End
Begin VB.TextBox txtDocument
Height = 4785
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 4
Top = 720
Width = 8130
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "File:"
Height = 195
Index = 1
Left = 420
TabIndex = 5
Top = 420
Width = 285
End
Begin HTTPCTLib.HTTPCT HTTP
Left = 7890
Top = 720
_ExtentX = 847
_ExtentY = 847
RemoteHost = "127.0.0.1"
RemotePort = 80
ConnectTimeout = 0
RecvTimeout = 0
NotificationMode= 1
Document = ""
Method = 1
End
Begin ComctlLib.ImageList Images
Left = 7890
Top = 1110
_Version = 65536
_ExtentX = 1005
_ExtentY = 1005
_StockProps = 1
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
NumImages = 3
i1 = "frmHTTP.frx":0442
i2 = "frmHTTP.frx":0641
i3 = "frmHTTP.frx":0840
End
Begin ComctlLib.Toolbar Tools
Height = 390
Left = 7035
TabIndex = 3
Top = 30
Width = 1125
_Version = 65536
_ExtentX = 1984
_ExtentY = 688
_StockProps = 96
ImageList = "Images"
AllowCustomize = 0 'False
NumButtons = 3
i1 = "frmHTTP.frx":0A3F
i2 = "frmHTTP.frx":0BF2
i3 = "frmHTTP.frx":0D9D
AlignSet = -1 'True
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Address:"
Height = 195
Index = 0
Left = 90
TabIndex = 0
Top = 90
Width = 615
End
Begin ComctlLib.StatusBar Status
Align = 2 'Align Bottom
Height = 270
Left = 0
TabIndex = 2
Top = 5535
Width = 8130
_Version = 65536
_ExtentX = 14340
_ExtentY = 476
_StockProps = 68
AlignSet = -1 'True
SimpleText = ""
NumPanels = 3
i1 = "frmHTTP.frx":0F48
i2 = "frmHTTP.frx":1015
i3 = "frmHTTP.frx":10E2
End
Attribute VB_Name = "frmHTTP"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
'------------------------------------------------------------
Dim httpDoc As String ' HTTP document download variable
Const btnRETRIEVE = 1 ' Toolbar button constant - Document retrieve button
Const btnHALT = 2 ' Toolbar button constant - Halt retrieve button
Const btnPOST = 3 ' Toolbar button constant - Post Document\File button
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub cmbURL_KeyDown(KeyCode As Integer, Shift As Integer)
'------------------------------------------------------------
If (KeyCode = vbKeyReturn) Then ' If user hit enter key...
Tools_ButtonClick Tools.Buttons(btnRETRIEVE) ' Click Retrieve button
End If
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub Form_Load()
'------------------------------------------------------------
Status.Panels(1).Text = HTTP.StateString ' Display HTTP state
Status.Panels(2).Text = HTTP.ProtocolStateString ' Display HTTP protocol state
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub HTTP_DocInput(ByVal DocInput As DocInput)
'------------------------------------------------------------
Select Case DocInput.State ' Determine state of HTTP upload
Case icDocBegin ' Beginning upload
Case icDocHeaders ' Uploading MIME-headers
Case icDocData ' Uploading data
Status.Panels(3).Text = "Sending Doc... [" & CStr(DocInput.BytesTransferred) & _
"] of [" & CStr(DocInput.BytesTotal) & "]" ' Display transfer status...
Case icDocEnd ' Upload complete
Status.Panels(3).Text = "" ' Clear status
End Select
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub HTTP_DocOutput(ByVal DocOutput As DocOutput)
'------------------------------------------------------------
Dim i As Long ' Loop variable
Dim Hdr As DocHeader ' Doc Header variable
Dim Data As String ' Data download variable
'------------------------------------------------------------
Select Case DocOutput.State ' Determine current state of download
Case icDocBegin ' Beginning download
httpDoc = "" ' Clear HTTP data variable
txtDocument.Text = "" ' Clear output textbox
Case icDocHeaders ' Downloading MIME-Headers
httpDoc = httpDoc & "= Begin Headers ========================================" & vbCrLf
For Each Hdr In DocOutput.Headers
httpDoc = httpDoc & Hdr.Name & ": " & Hdr.Value & vbCrLf
Next
httpDoc = httpDoc & "= End Headers ==========================================" & vbCrLf
Case icDocData ' Downloading data
Status.Panels(3).Text = "Getting Doc... [" & CStr(DocOutput.BytesTransferred) & _
"] of [" & CStr(DocOutput.BytesTotal) & "]" ' Display download status
DocOutput.GetData Data ' Get data from DocOutput object
httpDoc = httpDoc & Data ' Save data
Case icDocEnd ' Download complete
If (httpDoc <> "") Then ' If data was received...
txtDocument.Text = httpDoc ' Display output
Status.Panels(3).Text = "" ' Clear status
httpDoc = "" ' Clear data variable
cmbURL.Text = HTTP.URL ' Display updated\resolved URL
For i = 0 To cmbURL.ListCount - 1 ' Search each entry in DropDownCombo
If (cmbURL.List(i) = cmbURL.Text) Then Exit For ' If entry is duplicate then exit search
Next
If (i >= cmbURL.ListCount) Then cmbURL.AddItem HTTP.URL ' if item was not found then update DropDownCombo.
End If
Case Else ' Handle [Errors, etc...]
Status.Panels(3).Text = "" ' Clear status
' httpDoc = "" ' Clear data variable
End Select
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub HTTP_ProtocolStateChanged(ByVal ProtocolState As Integer)
'------------------------------------------------------------
Status.Panels(2).Text = HTTP.ProtocolStateString ' Display protocol state
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub HTTP_StateChanged(ByVal State As Integer)
'------------------------------------------------------------
Status.Panels(1).Text = HTTP.StateString ' Display state
Select Case State ' Determine current state
Case prcDisconnected ' Disconnected from server
Screen.MousePointer = vbDefault ' Show default pointer - transaction done.
Case Else
Screen.MousePointer = vbHourglass ' Not disconnected show that HTTP client is busy...
End Select
'------------------------------------------------------------
End Sub
'------------------------------------------------------------
'------------------------------------------------------------
Private Sub Tools_ButtonClick(ByVal Button As Button)
'------------------------------------------------------------
Dim Hdrs As DocHeaders ' Headers collection variable
Dim URL As String ' URL variable
Dim Pos As Long ' Substring position variable
'------------------------------------------------------------
Select Case Button.Index ' Determine which button was pushed
Case btnRETRIEVE ' Retrieve document button
URL = LCase(cmbURL.Text) ' Set url to all lowercase
If (Mid(URL, 1, 7) <> "http://") Then URL = "http://" & URL ' If HTTP prefix is missing then add it.
Pos = InStr(8, URL, "/") ' Search for proper HTTP suffix.
If (Pos < 1) Then URL = URL & "/" ' If suffix not found then add it.
HTTP.GetDoc URL ' Get URL document from HTTP server
Case btnHALT ' Halt retrieve button
HTTP.Cancel ' Halt\Cancel current transaction
Case btnPOST ' Post document\file button
' Set Hdrs = HTTP.DocInput.Headers ' Set pointer to headers collection
' Hdrs.Clear ' Clear any members of headers collection
' Hdrs.Add "", "" ' Add MIME-header to headers collection
' HTTP.SendDoc cmbURL.Text, Hdrs, , txtFileName.Text ' Post file with MIME-headers to URL...
HTTP.SendDoc cmbURL.Text, , , txtFileName.Text ' Post file to URL...
End Select
'------------------------------------------------------------
End Sub
'------------------------------------------------------------